package com.lebang.service;

import com.lebang.domain.EmailAuthority;
import com.lebang.example.EmailAuthorityExample;
import com.lebang.mapper.EmailAuthorityMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ljx
 * @date 2020/12/16
 */
@Service
public class EmailAuthorityService extends BaseService<EmailAuthority,Integer, EmailAuthorityExample>{
    @Autowired
    private EmailAuthorityMapper mapper;

    public List<Integer> selectByEmailId(Integer id) {
        return mapper.selectByEmailId(id);
    }

    public EmailAuthority selectByIdAndAppId(Integer id, Integer appId) {
        return mapper.selectByIdAndAppId(id,appId);
    }

    public int add(Integer emailId, Integer appId) {
        return mapper.add(emailId,appId);
    }

    public int updateRecord(EmailAuthority emailAuthority) {
        if (emailAuthority.getHasDeleted() == 0){
            emailAuthority.setHasDeleted(1);
        }else {
            emailAuthority.setHasDeleted(0);
        }
        return mapper.updateRecord(emailAuthority.getId(),emailAuthority.getHasDeleted());
    }

    public int deleteByEmailId(Integer emailId) {
        return mapper.deleteByEmailId(emailId);
    }
}
